function renderResults(results) {//
// create html results from json results array
//console.log("renderResults fired");
var results_html = "";
for(i in results) {
var item = results[i];
var title_html = '<div class="resulttitle">' + item.fields.result_title + '</div>';

results_html = results_html + title_html;
}
var titlename = "<h2> Saved Results </h2>";
results_html = titlename+results_html;
$('#floating-menu').html(results_html);

}
function loadAjaxResults(){
//console.log ("Loading previous results!");
var args = {   type:"GET",
 		       url:"/ajaxget/", 
		       success: function(results) { renderResults(results);}
			   };
        $.ajax(args);
		}

$(document).ready(function(){
	   $("button").click(function(){
	     var resultitle = $(this).parent().children("#resulttitle").html();
		 var resultdescription = $(this).parent().children("#resultdescription").html();
	     var args = { 
		             type:"POST",
 		             url:"/ajaxsave/", 
		             data: {'title':resultitle, 'description' : resultdescription},
             		 success: function(results) {renderResults(results);}
		           };
        $.ajax(args);
	   });
	 });

$(document).ready(function() {
loadAjaxResults();
});